package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"google.golang.org/grpc"
	"time"
	_ "web-server/config"
	"web-server/ioc"
	"web-server/pkg/jwt"
	"web-server/pkg/log"
)

func initGrpc() {
	grpc.NewServer()
}

func main() {
	logger := log.Default()

	router := ioc.InitServer()
	router.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})
	router.GET("/limit", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "limit",
		})
	})
	router.GET("/login", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"token": jwt.GenerateToken(2231),
		})
	})
	var a int
	for i := 0; i < 10000000; i++ {
		go func() {
			a++
		}()
	}
	time.Sleep(time.Second)
	fmt.Println(a)
	if err := router.Run(); err != nil {
		logger.Z.Error("start server failed", zap.Error(err))
	}

}
